Skip to content

feat(llc): add header and query-parameter redaction to LoggingInterceptor - #261

Open
xsahil03x wants to merge 14 commits into
mainfrom
fix/redact-urls-and-auth-in-logs
Open

xsahil03x wants to merge 14 commits into
mainfrom
fix/redact-urls-and-auth-in-logs

Conversation

@xsahil03x

@xsahil03x xsahil03x commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

Part of FLU-1379

What

  • LoggingInterceptor: gains redactedHeaders and redactedQueryParameters, modelled on OkHttp's HttpLoggingInterceptor (redactHeader / redactQueryParams). Named request and response headers and query parameters are logged as ***, matched regardless of case; in URLs only the named values change, keeping parameter order and encoding. redactedHeaders defaults to defaultRedactedHeaders (Authorization); spread it in to add more, or pass an empty collection to log every header as is.
  • UserToken: toString() leaves out the raw value, and the ArgumentError for a token without a user_id no longer includes it.

Verified

  • dart analyze --fatal-infos and all 986 stream_core tests pass, including a query parameter whose name isn't valid UTF-8.
  • Interceptor log output over 7 scenarios (header sets, query parameters in URLs and the table, response headers, compact and non-compact, error responses): with redaction off it is byte-for-byte identical to main; with redaction on it matches the output before the refactor of the redaction code.

🤖 Generated with Claude Code

xsahil03x and others added 2 commits November 25, 2026 13:14
- The WebSocket engine replaces the query string of any URL quoted in a
  socket error with <redacted> before the error reaches the logs or the
  reported StreamNetworkException. An error that quotes no URL query
  passes through unchanged.
- LoggingInterceptor reports the Authorization header as <redacted>.
- UserToken.toString() and the missing-user_id ArgumentError no longer
  include the raw token.
- The WebSocketOptions dartdoc example no longer puts a token in the
  query parameters.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The engine now hands a redacted error to the client as a plain Exception,
so the client still wraps it with its own message and cause. UserToken
also re-throws JWT parser errors without the value, the redaction is
documented on the engine and on requestHeader, and the tests use the
error shape dart:io produces.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@xsahil03x
xsahil03x requested a review from a team as a code owner November 25, 2026 12:23
@github-actions github-actions Bot added the ready Pull request ready to be reviewed label Nov 25, 2026
Replaces the URL-query scrubbing with a type-based mapping: a
package:web_socket WebSocketException, the one error whose text can
quote the connection URL, reaches the client as an exception reading
"The WebSocket connection failed". Other errors pass through unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov-commenter

codecov-commenter commented Nov 25, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.64%. Comparing base (c584c80) to head (befb747).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #261      +/-   ##
==========================================
+ Coverage   75.13%   75.64%   +0.50%     
==========================================
  Files         220      224       +4     
  Lines        9563     9804     +241     
==========================================
+ Hits         7185     7416     +231     
- Misses       2378     2388      +10     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

xsahil03x and others added 3 commits November 25, 2026 13:59
A value jose cannot parse is no working token, so its parse errors are
left as they are. The missing user_id error and toString() still leave
out the raw value.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Modelled on OkHttp's HttpLoggingInterceptor: the values of the named
headers (request and response) and query parameters are reported as
"██", matching names regardless of case. redactHeaders defaults to
Authorization; an empty set reports every header as is.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…xception

- Any WebSocketChannelException wrapping another error (every failure to
  open, including dart:io's HttpException that quotes the URL) is
  reported as a StreamNetworkException reading "The WebSocket connection
  failed". The web_socket dependency is no longer needed.
- LoggingInterceptor: redactedHeaders / redactedQueryParameters and a
  public defaultRedactedHeaders, matched through a case-insensitive set
  by small _redactHeader / _redactQueryParameter / _redactUrl helpers.
  Log output is unchanged.
- UserToken.toString() uses objectRuntimeType; docs and CHANGELOG follow
  the review.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@xsahil03x xsahil03x changed the title fix(llc): redact URL queries and the Authorization header in logs and errors feat(llc): redact headers in HTTP logs and report failed WebSocket opens without their URL Nov 25, 2026
The engine passes socket failures through untouched again, and the
client keeps wrapping them as a StreamNetworkException with the original
error as its cause, the shape OkHttp and the Android SDK use.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@xsahil03x xsahil03x changed the title feat(llc): redact headers in HTTP logs and report failed WebSocket opens without their URL feat(llc): add header and query-parameter redaction to LoggingInterceptor Nov 25, 2026
Restores the engine change: dart:io quotes the connection URL in the
errors it raises while connecting, so a WebSocketChannelException
wrapping another error is reported as a StreamNetworkException reading
"The WebSocket connection failed". This gives the engine the guarantee
OkHttp's transport has by construction: its errors carry no URL.

LoggingInterceptor now redacts URL query parameters in the raw query,
keeping order and encoding of the rest, and matches decoded names.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@xsahil03x xsahil03x changed the title feat(llc): add header and query-parameter redaction to LoggingInterceptor feat(llc): add log redaction to LoggingInterceptor and report failed WebSocket opens as StreamNetworkException Nov 25, 2026
Like OkHttp, ws and Python's websockets, the engine reports a failed
open as the transport raised it, and the client wraps it with the
original as its cause. Credentials leaving the URL (first-message auth)
is what keeps them out of those errors.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@xsahil03x xsahil03x changed the title feat(llc): add log redaction to LoggingInterceptor and report failed WebSocket opens as StreamNetworkException feat(llc): add header and query-parameter redaction to LoggingInterceptor Nov 25, 2026
xsahil03x and others added 5 commits November 25, 2026 15:04
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Matching stays case-insensitive; a test covers a lowercase header.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Also types defaultRedactedHeaders as Iterable<String> and tightens the
constructor docs and changelog.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready Pull request ready to be reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants